package com.i18n.test;

import java.text.MessageFormat;
import java.util.Locale;
import java.util.ResourceBundle;

public class I18nSample {
	public static void main(String[] args) {
		Locale defaultLocale = Locale.getDefault();
		System.out.println("default Country=" + defaultLocale.getCountry());
		System.out.println("default Language=" + defaultLocale.getLanguage());

		Locale currentLocale = new Locale("en", "US");
//		 Locale currentLocale=new Locale("zh","CN");
		
		// 如果资源文件不是放在根目录则要加上目录名
//		ResourceBundle rb = ResourceBundle.getBundle("res.MessageBundle", currentLocale);
		ResourceBundle rb = ResourceBundle.getBundle("MessageBundle", currentLocale);
	
//		System.out.println(rb.getString("k1"));
//		System.out.println(rb.getString("k2"));

		MessageFormat mf1=new MessageFormat(rb.getString("k1"));
		MessageFormat mf2=new MessageFormat(rb.getString("k2"));
		Object[] ob=new Object[]{"jqblizzie"};
		System.out.println(mf1.format(ob));
		System.out.println(mf2.format(ob));
	}
}
